﻿using System;
using System.Collections.Generic;
using System.Linq;
using AcademicPlanner.Domain.Models.Collections;

namespace AcademicPlanner.Domain.Models
{
	/// <summary>
	/// MainModel represents the top level model of the AcademicPlanner 
	/// application. It holds references to models that do not aggreagately
	/// belong to any model and serves as an accessor to all system wide
	/// models.
	/// </summary>
	/// <version>1.0</version>
	/// <since>1.0</since>
    public class MainModel
    {
		private PersonCollection allPeople;

		private AccountCollection allAccounts;


		/// <summary>
		/// Gets the collection of all <c>Person</c>s in the system.
		/// </summary>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public PersonCollection AllPeople { get {return allPeople; } }

		/// <summary>
		/// Gets the collection of all <c>Account</c>s in the system.
		/// </summary>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public AccountCollection AllAccounts { get { return allAccounts; } }


		private MainModel() 
		{
			allPeople = new PersonCollection();
			allAccounts = new AccountCollection();
		}

		private class InstanceHolder 
		{
			internal static MainModel INSTANCE = new MainModel(); 
		}


		/// <summary>
		/// Gets the single MainModel instance.
		/// </summary>
		/// <returns>The single MainModel instance.</returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public static MainModel GetInstance()
		{ 
			return InstanceHolder.INSTANCE; 
		}
    }
}
